﻿using System;
using Microsoft.EntityFrameworkCore;

namespace EFEntity
{
    public class MyDbContext:DbContext
    {
        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            optionsBuilder.UseSqlServer("Data Source=.;Initial Catalog=人力资源管理;Integrated Security=True");
        }
        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            //公共字段设置，包括薪酬设置，职称设置，国籍，民族，宗教信
            var econfig_public_char = modelBuilder.Entity<Econfig_public_char>();
            econfig_public_char.ToTable("config_public_char");
            econfig_public_char.Property(e => e.attribute_kind).HasMaxLength(60);
            econfig_public_char.Property(e => e.attribute_name).HasMaxLength(60);
            //薪酬标准单详细信息 
            var esalary_standard_details = modelBuilder.Entity<Esalary_standard_details>();
            esalary_standard_details.ToTable("salary_standard_details");
            esalary_standard_details.Property(e => e.standard_id).HasMaxLength(30);
            esalary_standard_details.Property(e => e.standard_name).HasMaxLength(60);
            esalary_standard_details.Property(e => e.item_id).HasMaxLength(20);
            esalary_standard_details.Property(e => e.item_name).HasMaxLength(60);
            esalary_standard_details.Property(e => e.salary);
            //薪酬标准基本信息表
            var esalary_standard = modelBuilder.Entity<Esalary_standard>();
            esalary_standard.ToTable("salary_standard");
            esalary_standard.Property(e => e.standard_id).HasMaxLength(30);
            esalary_standard.Property(e => e.standard_name).HasMaxLength(60);
            esalary_standard.Property(e => e.designer).HasMaxLength(60);
            esalary_standard.Property(e => e.register).HasMaxLength(60);
            esalary_standard.Property(e => e.checker).HasMaxLength(60);
            esalary_standard.Property(e => e.changer).HasMaxLength(60);
            esalary_standard.Property(e => e.regist_time);
            esalary_standard.Property(e => e.check_time);
            esalary_standard.Property(e => e.change_time);
            esalary_standard.Property(e => e.salary_sum);
            esalary_standard.Property(e => e.check_status).HasMaxLength(20);
            esalary_standard.Property(e => e.change_status).HasMaxLength(20);
            esalary_standard.Property(e => e.check_comment).HasMaxLength(60);
            esalary_standard.Property(e => e.remark).HasMaxLength(60);
             //薪酬发放登记表
            var eg = modelBuilder.Entity<Esalary_grant>();
            eg.ToTable("salary_grant");
            eg.Property(e => e.salary_grant_id).HasMaxLength(50);
            eg.Property(e => e.salary_standard_id).HasMaxLength(50);
            eg.Property(e => e.first_kind_id).HasMaxLength(50);
            eg.Property(e => e.first_kind_name).HasMaxLength(50);
            eg.Property(e => e.second_kind_id).HasMaxLength(50);
            eg.Property(e => e.second_kind_name).HasMaxLength(50);
            eg.Property(e => e.third_kind_id).HasMaxLength(50);
            eg.Property(e => e.third_kind_name).HasMaxLength(50);
            eg.Property(e => e.human_amount).HasMaxLength(50);
            eg.Property(e => e.salary_standard_sum);
            eg.Property(e => e.salary_paid_sum);
            eg.Property(e => e.register).HasMaxLength(50);
            eg.Property(e => e.regist_time);
            eg.Property(e => e.checker).HasMaxLength(50);
            eg.Property(e => e.check_time);
            eg.Property(e => e.check_status).HasMaxLength(50);


            //薪酬发放详细信息
            var esg = modelBuilder.Entity<Esalary_grant_details>();
            esg.ToTable("salary_grant_details");
            esg.Property(e => e.salary_grant_id).HasMaxLength(50);
            esg.Property(e => e.human_id).HasMaxLength(50);
            esg.Property(e => e.human_name).HasMaxLength(50);
            esg.Property(e => e.bouns_sum);
            esg.Property(e => e.sale_sum);
            esg.Property(e => e.deduct_sum);
            esg.Property(e => e.salary_standard_sum);
            esg.Property(e => e.salary_paid_sum);

        }

        /// <summary>
        /// 用户名
        /// </summary>
        public DbSet<Eusers> Users { get; set; }
       
        /// <summary>
        /// 公共属性设置
        /// </summary>
        public DbSet<Econfig_public_char> Cpc { get; set; }
        /// <summary>
        /// 薪酬发放登记表
        /// </summary>
        public DbSet<Esalary_standard> Eess { get; set; }
        /// <summary>
        /// 薪酬标准单详细信息
        /// </summary>
        public DbSet<Esalary_standard_details> Essd { get; set; }
        
        /// <summary>
        /// 薪酬发放详细信息
        /// </summary>
        public DbSet<Esalary_grant_details> Esgd { get; set; }
        /// <summary>
        /// 薪酬发放登记表
        /// </summary>
        public DbSet<Esalary_grant> Esg { get; set; }
    }
}
